package com.andy;

import com.andy.service.DemoService;
import com.andy.service.HelloService;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class TPConsumerStarter {
    
    public static void main(String[] args){
        ClassPathXmlApplicationContext context =
                new ClassPathXmlApplicationContext("dubbo-comsumer.xml");
        context.start();

        System.out.println("consumer 启动完成");

        DemoService demoService = context.getBean(DemoService.class);
        ThreadPoolExecutor executor = new ThreadPoolExecutor(
                4,
                4,
                30,
                TimeUnit.SECONDS,
                new LinkedBlockingQueue <>(10000));

        while(true){
            executor.execute(()->{
                demoService.demo01();
                demoService.demo02();
                demoService.demo03();
            });

            try {
                Thread.sleep(30);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }

    }
}
